package com.ship.dispatch.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ship.common.datasource.annotation.Slave;
import com.ship.dispatch.bean.SpInformation;
import com.ship.dispatch.bean.boats.QueryBoatsBaseRq;
import com.ship.dispatch.bean.boats.info.QueryBoatsPortSisterInfo;
import com.ship.dispatch.bean.boats.info.QueryShipMessageInfo;
import com.ship.dispatch.bean.treaShipNetwork.IhsShipBaseList;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 船舶信息 Mapper 接口
 * </p>
 *
 * @author AbyssRabbit@163.com
 * @since 2023-10-18
 */
public interface SpInformationMapper extends BaseMapper<SpInformation> {

    @Insert("INSERT INTO ihs_ship_base_file (id, url, imo,file_name) VALUES (#{id}, #{url}, #{imo}, #{fileName})")
    void upFile(@Param("id") String id, @Param("url") String url, @Param("imo") String imo,@Param("fileName") String fileName);

    @Delete("DELETE FROM ihs_ship_base_file WHERE id = #{id}")
    void deleteById(String id);
    @Select("SELECT id fileId,file_name fileName ,url FROM ihs_ship_base_file WHERE imo = #{imo}")
    List<Map<String,Object>> getFromB(@Param("imo") String imo);

    @Select("SELECT imo FROM ihs_ship_base WHERE id = #{id}")
    @Slave
    String getImoById(String id);

    @Select("SELECT update_time FROM ihs_ship_base WHERE imo = #{imo}")
    @Slave
    String getShipInfoDetailTime(String imo);

    @Select("Select url FROM ihs_ship_base_file WHERE id = #{id}")
    String getByInfoID(String id);

    @Select("Select id FROM ihs_ship_base_file WHERE imo = #{imo}")
    String getFileByImo(String imo);

    @Slave
    String queryMmsiByShipName(@Param("shipName") String shipName,@Param("imo") String imo);

    @Slave
    List<QueryShipMessageInfo> queryShipMessage(@Param("shipName") String shipName, @Param("imo") String imo);

   @Slave
    SpInformation queryShipImoByShipName(@Param("vesselName") String vesselName);

    @Slave
    SpInformation queryShipByShipName(@Param("shipName")  String shipName,@Param("imo")  String imo);


    @Delete("DELETE FROM ihs_ship_base_file WHERE id = #{id}")
    boolean deleteFromBById(@Param("id") Long id);

    @Slave
    IhsShipBaseList queryShipBaseByShipName(@Param("shipName") String shipName,@Param("imo") String imo);
}